package com.xyz.tasks.tdo;

import com.free.ext.logger.FreeLogger;
import com.free.ext.logger.FreeLoggerFactory;
import com.free.ext.quartz.TaskContainer;
import com.free.ext.quartz.model.TaskRes;
import com.free.ext.quartz.tasker.RemoteUrlTasker;
import com.xyz.domain.constants.ConstantsLotteryTaskFormater;
import com.xyz.domain.table.SLottery;

public class EndTasker extends RemoteUrlTasker {

    private static final FreeLogger LOG = FreeLoggerFactory.getLogger(StartTasker.class);

    @Override
    public TaskRes execute() {
        if(!this.getParams().containsKey(ConstantsLotteryTaskFormater.LOTTERY_TASK_PARAM_OBJ)){
            return TaskRes.error(null);
        }
        LOG.info("结束进程被唤醒");
        SLottery lotteryInfo = (SLottery)this.getParams().get(ConstantsLotteryTaskFormater.LOTTERY_TASK_PARAM_OBJ);
        String lotteryCode = String.format(ConstantsLotteryTaskFormater.LOTTERY_TASK_CODE_PROC, lotteryInfo.getCode());
        LOG.info("结束进程被唤醒 正常暂停定时任务{}-{}",ConstantsLotteryTaskFormater.LOTTERY_TASK_GROUP,lotteryInfo.getCode());
        TaskContainer.instance().pause(ConstantsLotteryTaskFormater.LOTTERY_TASK_GROUP, lotteryCode);
        return null;
    }

}
